package com.dmooo.yxmmerchant.view.model;

import android.content.Context;

import com.common.net.entity.SubjectPost;
import com.common.net.listener.HttpOnNextListener;
import com.common.net.subscribers.ProgressSubscriber;
import com.common.util.LogUtil;
import com.dmooo.yxmmerchant.http.HttpManager;
import com.dmooo.yxmmerchant.view.contract.BankContract;

import java.util.HashMap;
import java.util.Map;

public class BankModel implements BankContract.BankMdl {
    private Context context;
    public BankModel(Context context){
        this.context=context;
    }
    @Override
    public void addBank(Map<String, Object> map, HttpOnNextListener listener) {
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"添加中"),map);
        HttpManager.getInstance().addUserBank(post);
    }

    @Override
    public void deleteBank(String token, String id,int index, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("token",token);
        map.put("id",id);
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"删除中"),map);
        HttpManager.getInstance().delUserBank(post);
    }

    @Override
    public void getBankType(HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,false,true,""),map);
        HttpManager.getInstance().getBankTypeList(post);
    }

    @Override
    public void getMyBankList(String token, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("token",token);
        LogUtil.d("dsfasd",token);
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,false,true,""),map);
        HttpManager.getInstance().getUserBank(post);
    }
}
